var status = -1;
var selectionLog = [];
var items = [1182193];

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            im.dispose();
            for (var a = 4020000; a <= 4020008; a++) {
                items.push(a)
            }
            for (var a = 4021000; a <= 4021016; a++) {
                items.push(a)
            }
            for (var a = 4022000; a <= 4022021; a++) {
                items.push(a)
            }
            for (var a = 4023000; a <= 4023026; a++) {
                items.push(a)
            }
            for (var a = 4024000; a <= 4024007; a++) {
                items.push(a)
            }
            for (var a = 4025000; a <= 4025011; a++) {
                items.push(a)
            }
            var e = im.getItemId();
            im.gainItem(e, -1);
            im.gainItem(items[im.rand(0, items.length)], 1);
            im.gainItem(4310020, im.rand(5, 30))
        }
    }
};